// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Aggregations;

[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Aggregations.Json.WeightedAverageAggregationConverter))]
public sealed partial class WeightedAverageAggregation
{
#if NET7_0_OR_GREATER
	public WeightedAverageAggregation()
	{
	}
#endif
#if !NET7_0_OR_GREATER
	public WeightedAverageAggregation()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	/// <summary>
	/// <para>
	/// A numeric response formatter.
	/// </para>
	/// </summary>
	public string? Format { get; set; }

	/// <summary>
	/// <para>
	/// Configuration for the field that provides the values.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValue? Value { get; set; }
	public Elastic.Clients.Elasticsearch.Aggregations.ValueType? ValueType { get; set; }

	/// <summary>
	/// <para>
	/// Configuration for the field or script that provides the weights.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValue? Weight { get; set; }
}

public readonly partial struct WeightedAverageAggregationDescriptor<TDocument>
{
	internal Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public WeightedAverageAggregationDescriptor(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public WeightedAverageAggregationDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument>(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation instance) => new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument>(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// A numeric response formatter.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> Format(string? value)
	{
		Instance.Format = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field that provides the values.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> Value(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValue? value)
	{
		Instance.Value = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field that provides the values.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> Value()
	{
		Instance.Value = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<TDocument>.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field that provides the values.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> Value(System.Action<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<TDocument>>? action)
	{
		Instance.Value = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<TDocument>.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> ValueType(Elastic.Clients.Elasticsearch.Aggregations.ValueType? value)
	{
		Instance.ValueType = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field or script that provides the weights.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> Weight(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValue? value)
	{
		Instance.Weight = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field or script that provides the weights.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> Weight()
	{
		Instance.Weight = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<TDocument>.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field or script that provides the weights.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument> Weight(System.Action<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<TDocument>>? action)
	{
		Instance.Weight = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<TDocument>.Build(action);
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation Build(System.Action<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument>>? action)
	{
		if (action is null)
		{
			return new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
		}

		var builder = new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor<TDocument>(new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}

public readonly partial struct WeightedAverageAggregationDescriptor
{
	internal Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public WeightedAverageAggregationDescriptor(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public WeightedAverageAggregationDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation instance) => new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// A numeric response formatter.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Format(string? value)
	{
		Instance.Format = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field that provides the values.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Value(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValue? value)
	{
		Instance.Value = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field that provides the values.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Value()
	{
		Instance.Value = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field that provides the values.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Value(System.Action<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor>? action)
	{
		Instance.Value = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor.Build(action);
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field that provides the values.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Value<T>(System.Action<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<T>>? action)
	{
		Instance.Value = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<T>.Build(action);
		return this;
	}

	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor ValueType(Elastic.Clients.Elasticsearch.Aggregations.ValueType? value)
	{
		Instance.ValueType = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field or script that provides the weights.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Weight(Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValue? value)
	{
		Instance.Weight = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field or script that provides the weights.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Weight()
	{
		Instance.Weight = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor.Build(null);
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field or script that provides the weights.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Weight(System.Action<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor>? action)
	{
		Instance.Weight = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor.Build(action);
		return this;
	}

	/// <summary>
	/// <para>
	/// Configuration for the field or script that provides the weights.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor Weight<T>(System.Action<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<T>>? action)
	{
		Instance.Weight = Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageValueDescriptor<T>.Build(action);
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation Build(System.Action<Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor>? action)
	{
		if (action is null)
		{
			return new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
		}

		var builder = new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregationDescriptor(new Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}